
package threadlogging.log4j;

import java.io.IOException;
import java.io.PrintWriter;

import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.log4j.Logger;

public class NullPointerExceptionServlet extends HttpServlet
{
	private static final Logger log = Logger.getLogger(NullPointerExceptionServlet.class);
	
	public void service(HttpServletRequest req, HttpServletResponse rsp)
		throws IOException
	{
		log.debug("a debug message");
		
		log.info("an info message");
		
		try
		{
			String s = null;
			System.out.println(s.toUpperCase());
		}
		catch (Exception ex)
		{
			log.error("caught something", ex);
		}
		finally
		{
			log.info("another info message");
		}
		
		PrintWriter writer = rsp.getWriter();
		writer.write(this.getClass().getName());
		writer.flush();
		
	}
}
